<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
                margin: 0px;
                padding: 0px;
                list-style: none;
            }
        div{
                background-image: url(images/pic.jpg) ;
                
            }
        h1{
            color:rgb(0, 140, 255);
            font-size: 100px;
            text-align: center;
            margin-top: 20px;
        }

    </style>
</head>
<body>
    <button id="start">开始</button>
        <button id="end">停止</button>
        <div>
            <h1 id="txt">
            被抽到的人学习3小时
        </h1> 
        </div>
                   

            

        <script>
            var start=document.getElementById('start')
            var end=document.getElementById('end')
            var txt=document.getElementById('txt');
            var timer;
            var list=['邓子键','李嘉轩','陈浩铭','游德豪','李杰','陈志文'];
            console.log(list[0]);
            console.log(list.length)
            start.onclick=function(){
                clearInterval(timer)
               timer=setInterval(function(){
                    var n=parseInt(Math.random()*list.length);
                    txt.innerHTML=list[n];
                },10)
            }
            end.onclick=function(){
                clearInterval(timer);
            }
        </script>
</body>
</html>